package it.tukano.swingdeco.containers;

import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JScrollPane;

/** JScrollPane extension */
public class JScrollPaneExt extends JScrollPane {

    /* Serial version of this class */
    private static final long serialVersionUID = 0;

    /**
     * Instance initializer
     */
    public JScrollPaneExt() {
    }

    /**
     * Initializes this scroll pane using the given view
     * @param view the component shown by this scroller
     */
    public JScrollPaneExt(Component view) {
        super(view);
    }

    /**
     * Set the component displayed by the viewport of this scroll pane
     * @param c the component to display
     * @return this
     */
    public JScrollPaneExt show(Component c) {
        setViewportView(c);
        return this;
    }

    public JScrollPaneExt withVBarVisible() {
        setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        return this;
    }

    public JScrollPaneExt withPreferredSize(int w, int h) {
        setPreferredSize(new Dimension(w, h));
        return this;
    }
}
